package cn.bone.springcloud.service.impl;

import cn.bone.springcloud.base.bean.CommonResult;
import cn.bone.springcloud.base.bean.Ref;
import cn.bone.springcloud.bean.Payment;
import cn.bone.springcloud.mapper.PaymentMapper;
import cn.bone.springcloud.service.IPaymentService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Service
@Transactional
public class PaymentServiceImpl implements IPaymentService {

    @Value("${server.port}")
    private String serverPort;

    @Resource
    private PaymentMapper paymentMapper;
    /*新增*/
    public CommonResult add(String serial){
        Payment payment = new Payment();
        payment.setSerial(serial);
        paymentMapper.insert(payment);
        return Ref.okMessage("成功, 服务端口:"+serverPort);
    }

    /*根据id查询*/
    public CommonResult get(Integer id){
        Payment payment = paymentMapper.selectById(id);
        return Ref.okMessage(payment, "成功, 服务端口:"+serverPort);
    }

    /*新增实体类*/
    public CommonResult create(Payment payment){
        paymentMapper.insert(payment);
        return Ref.okMessage("成功, 服务端口:"+serverPort);
    }
}
